/**
 * @description 建立聊天连接
 */

import MessageSocket from '@/assets/js/socket-connect.js';
export default {
    namespaced: true,
    state: {
        socket: ''
    },
    mutations: {
        //连接socket
        INIT_CONNECT_SOCKET (state, object) {
            let socket = new MessageSocket(this, {
                socketUrl: object.socketUrl,
                chat_no: object.chat_no,
                session_no: object.session_no
            });

            state.socket = socket;
        },

        //关闭socket
        CLOSE_SOCKET_CONNECT (state) {
            state.socket.ws.close();
        }
    }
};
